package auto.app.job;


import auto.app.service.TestCollectionService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTaskJob {

    @Autowired
    private TestCollectionService testCollectionService;


    @XxlJob(value = "scheduledExecutionCollection")
    public void executeJob() throws Exception {
        XxlJobHelper.log("scheduledExecutionCollection => 01  run  当前线程名称 {} ", Thread.currentThread().getName());
        String collectionId = XxlJobHelper.getJobParam();
        if (!ObjectUtils.isEmpty(collectionId)){
            Boolean execute = testCollectionService.execute(Integer.parseInt(collectionId),true,null,null);
            XxlJobHelper.log("scheduledExecutionCollection => 01  run  当前线程名称 {} ,执行测试合集{} 且执行结果为{}", Thread.currentThread().getName(),collectionId,execute);
        }else{
            XxlJobHelper.log("scheduledExecutionCollection => 01  run  当前线程名称 {} ", Thread.currentThread().getName());
        }
    }
}
